<?php

	header("Content-Type: text/html;charset=utf-8");

	include("../_judge.php");

	include("../../function/function.php");

	

	$keys = chkstr(trim($_REQUEST['keys']));

	$order_state = chkstr(trim($_REQUEST['order_state']));

	$order_states = chkstr(trim($_REQUEST['order_states']));

	$records = chkstr(trim($_REQUEST['records']));

	$page = chkstr(trim($_REQUEST['page']));
	$news_aid = chkstr(trim($_REQUEST['news_aid']));
	
	

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title><?= $adminweb_titles ?></title>

<link href="../css/style.css" rel="stylesheet" type="text/css" />

<script>if (top.location != parent.location||self.location==top.location){top.location.replace('../login/admin.php')}</script>

<script language="javascript" src="../script/jquery-1.7.2.min.js"></script>

<script language="javascript" src="../script/My97DatePicker/WdatePicker.js"></script>

<script type="text/javascript" src="../script/weebox/bgiframe.js"></script>

<script type="text/javascript" src="../script/weebox/weebox.js"></script>

<link type="text/css" rel="stylesheet" href="../script/weebox/weebox.css" />

<script language="javascript">

$(document).ready(function(){

	$(".orderwin").click(function(){

		Nids=$(this).attr("msg")

		$.weeboxs.open("newsorderm.php?id="+Nids+"&rnds="+ Math.random(),{

			title: '信息查看',

			contentType:'ajax',

			width:500,

			height:300,

			//contentType:'iframe',

			showButton:false,

			modal: true,

			draggable: true

			

		});

	});

	$(".orderwins").click(function(){

		Nids=$(this).attr("msg")

		$.weeboxs.open("ordertui.php?id="+Nids+"&rnds="+ Math.random(),{

			title: '查看退款信息',

			contentType:'ajax',

			width:500,

			height:300,

			//contentType:'iframe',

			showButton:false,

			modal: true,

			draggable: true

			

		});

	});

	$(".orderwinstui").click(function(){

		Nids=$(this).attr("msg")

		$.weeboxs.open("ordertuiactive.php?id="+Nids+"&rnds="+ Math.random(),{

			title: '查看退出活动信息',

			contentType:'ajax',

			width:500,

			height:300,

			//contentType:'iframe',

			showButton:false,

			modal: true,

			draggable: true

			

		});

	});



	$("#ckall").click(function(){

		if(this.checked){

			$("input[name='newsid[]']").attr('checked', true)  

		}else{   

			$("input[name='newsid[]']").attr('checked', false)  

		}   

	});

	

});

	function del(){

		if (!confirm("您确定要执行此操作吗？")) return false;

	}

</script>

</head>



<body>



<table width="97%" border="0" align="center" cellpadding="5" cellspacing="0">

  <tr>

    <td><strong>后台管理</strong>&nbsp;-&nbsp;<span class="hong"><strong>会员管理</strong></span></td>

  </tr>

</table>

<form action="newsmanage.php" method="get" name="searchForm" id="searchForm">

<table width="97%" border="0" align="center" cellpadding="5" cellspacing="0" bgcolor="#336699">

  <tr>

    <td><span class="bai12">搜索：</span>

      <input name="keys" type="text" id="keys" value="<?= $keys ?>" />

      <select name="order_state">

        <option value=""<? if($order_state == ""){ echo " selected";}?>>支付状态</option>

        <option value="0"<? if($order_state == "0"){ echo " selected";}?>>失败</option>

        <option value="1"<? if($order_state == "1"){ echo " selected";}?>>成功</option>

		<option value="2"<? if($order_state == "2"){ echo " selected";}?>>申请退款</option>

		<option value="3"<? if($order_state == "3"){ echo " selected";}?>>退款成功</option>

      </select>

	  <select name="order_states">

        <option value=""<? if($order_state == ""){ echo " selected";}?>>订单状态</option>

		<option value="1"<? if($order_state == "1"){ echo " selected";}?>>申请退款</option>

		<option value="2"<? if($order_state == "2"){ echo " selected";}?>>退款成功</option>

		<option value="4"<? if($order_state == "4"){ echo " selected";}?>>申请退出活动</option>

		<option value="5"<? if($order_state == "5"){ echo " selected";}?>>退出活动成功</option>

      </select>
	  
	  
	  <select name="news_aid">
	  <option value="">==请选择活动==</option>
	  <?php
	  		$active_sql = "select * from kboy_forum_active order by id desc";
			$active_rows = mysql_query($active_sql);
			while($active_rs = mysql_fetch_array($active_rows)){
				if($news_aid == $active_rs['id']){
					echo "<option value=\"".$active_rs['id']."\" selected>".$active_rs['active_title']."</option>";
				}else{
					echo "<option value=\"".$active_rs['id']."\">".$active_rs['active_title']."</option>";
				}
			}
	  ?>
      </select>
	  

      <input type="submit" name="ss" value="搜 索" class="button2" /></td>

    <td align="right"><span class="bai12">每页显示：</span>

      <input name="records" type="text" id="records" value="<?php if(strlen($records)>0){echo $records;}else{echo "20";} ?>" size="10" onblur="this.value=this.value.replace(/\D/g,'')" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" />

      <span class="bai12">条</span></td>

  </tr>

</table>

</form>

<br />

<form action="newsaddsave.php?action=del" method="post" name="myform" id="myform">

<table width="97%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#000000">

  <tr bgcolor="#336699">

    <td width="40" height="25" align="center"><span class="bai12">选定</span></td>

    <td align="center"><span class="bai12">用户</span></td>

    <td align="center"><span class="bai12">订单号</span></td>

    <td align="center"><span class="bai12">活动</span></td>

    <td align="center"><span class="bai12">真实姓名</span></td>

    <td align="center"><span class="bai12">手机号</span></td>

    <td align="center"><span class="bai12">身份证号</span></td>

    <td align="center"><span class="bai12">上车地点</span></td>

    <td align="center"><span class="bai12">备注</span></td>

    <td align="center"><span class="bai12">是否全款</span></td>

    <td align="center"><span class="bai12">支付方式</span></td>

    <td align="center"><span class="bai12">支付状态</span></td>

    <td align="center"><span class="bai12">下单时间</span></td>

    </tr>

  

  <?php

		$SQL = "";

		if(!empty($keys)){

			if(!empty($SQL)){

				$SQL = $SQL." and order_realname like '%".$keys."%' or  order_no like '%".$keys."%'";

			}else{

				$SQL = " order_realname like '%".$keys."%' or  order_no like '%".$keys."%'";

			}

		}

		if($order_state !=""){

			if(!empty($SQL)){

				$SQL = $SQL ." and order_state=$order_state";

			}else{

				$SQL = " order_state=$order_state";

			}

		}

		if($order_states !=""){

			if(!empty($SQL)){

				$SQL = $SQL ." and order_states=$order_states";

			}else{

				$SQL = " order_states=$order_states";

			}

		}
		
		if($news_aid !=""){

			if(!empty($SQL)){

				$SQL = $SQL ." and aid=$news_aid";

			}else{

				$SQL = " aid=$news_aid";

			}

		}

		

		

		

		



		if(strlen($records)>0){

			$pagesize = $records; //分页数量

		}else{

			$pagesize = 20; //分页数量

		}

		

		if(strlen($page) > 0){

			$pageval = $page;

			if($pageval <= 0){

				$pageval = 1;

			}

			$page = ($pageval-1)*$pagesize;

			$page .= ",";

		}

		//分页链接地址

		$url="newsmanage.php?order_state=$order_state&news_aid=$news_aid&";



		if(empty($SQL)){

			$numsql = "select * from kboy_order order by id desc";

		}else{

			$numsql = "select * from kboy_order where ".$SQL." order by id desc";

		}



		$news_sql = $numsql." limit $page $pagesize";

		$news_nums = mysql_num_rows(mysql_query($numsql));

		$pagecount = ceil($news_nums / $pagesize);

		$news_rows = mysql_query($news_sql);

		$i = 1;

		while($news_rs = mysql_fetch_array($news_rows)){

?>

		  <tr bgcolor="#efefef" onMouseOver="this.style.background='#C9C9C9'" onMouseOut="this.style.background='#efefef'" >

			<td height="25" align="center"><input type="checkbox" name="newsid[]" id="newsid" value="<?=$news_rs['id'] ?>" /></td>

			<td align="center"><?=getUserNickName($news_rs['uid'])?></td>

			<td align="center"><?=$news_rs['order_no']?><?php if($news_rs['order_states'] == 1 ){ echo "<a href=\"javascript:void(0);\" msg=\"".$news_rs['id']."\"  class=\"orderwins\" style=\"color:#FF0000\">[申请退款]</a>";} ?><?php if($news_rs['order_states'] == 2 ){ echo "<a href=\"javascript:void(0);\" msg=\"".$news_rs['id']."\"  class=\"orderwins\" style=\"color:#FF0000\">[已经退款]</a>";}

			if($news_rs['order_states'] == 4 ){ echo "<a href=\"javascript:void(0);\" msg=\"".$news_rs['id']."\"  class=\"orderwinstui\" style=\"color:#FF0000\">[申请退出活动]</a>";}

			if($news_rs['order_states'] == 5 ){ echo "<a href=\"javascript:void(0);\" msg=\"".$news_rs['id']."\"  class=\"orderwinstui\" style=\"color:#FF0000\">[退出活动成功]</a>";}

			 ?></td>

			<td align="center"><a href="/activeview.php?newsid=<?=$news_rs['aid']?>" target="_blank">点击查看</a></td>

			<td align="center"><?=$news_rs['order_realname']?></td>

			<td align="center"><?=$news_rs['order_phone']?></td>

			<td align="center"><?=$news_rs['order_idcard']?></td>

			<td align="center"><?=$news_rs['order_shangche']?></td>

			<td align="center"><?=$news_rs['order_text']?></td>

			<td align="center">

			<?php

				if($news_rs['order_isfull'] == 1){

					echo "全款";

				}else{

					echo "预付款";

				}

			?>			</td>

			<td align="center"><?php
				if($news_rs['order_payway'] == 0){
					echo "支付宝";
				}else if($news_rs['order_payway'] == 1){
					echo "线下";
				}else if($news_rs['order_payway'] == 2 ){
				    echo "微信";
				}else if($news_rs['order_payway'] == 3 ){
				    echo "余额";
				}

			?></td>

			<td align="center">

			<?php

					if($news_rs['order_state'] == 1){

						echo "支付成功";

					}else{

						echo "失败";

					}

			?>			</td>

			<td align="center">

			<?=$news_rs['order_addtime']?>			</td>

		  </tr>

			<?php

		}// while结束

		

		if($news_nums > 0){

			?>

		  <tr bgcolor="#efefef">

			<td height="25" colspan="13">&nbsp;

			  <input type="checkbox" name="ckall" value="ckall" id="ckall" />

			  &nbsp;全选&nbsp;

			  <select name="news_option" id="news_option">

				<option value="">请选择操作</option>

				<option value="del">删除</option>

				<option value="tuimoney">确认退款</option>

				<option value="tuiactive">确认退出活动</option>

			  </select>

			  &nbsp;

			  <input type="submit" name="submit2" value="执行" onClick="return del();" class="button2" />			</td>

		  </tr>

			<?php

		}

			?>

</table>

</form>

<form action="<?=$url?>" method="post" name="pageform" id="pageform">

<table width="90%" border="0" align="center" cellpadding="10" cellspacing="0">

    <tr>

      <td height="30" align="center">

	  <?php

			if($news_nums > $pagesize){

				if ($pageval<=1){

					$pageval=1;

					echo "首页&nbsp;&nbsp;";

				}else{

					echo "<a href=".$url."page=1>首页</a>&nbsp;&nbsp;";

				}

					if ($pageval<=1){

					echo "上一页</a>&nbsp;&nbsp;";

					}else{

					echo "<a href=".$url."page=".($pageval-1).">上一页</a>&nbsp;&nbsp;";

					}

					

					if ($pageval>=$pagecount){

					echo "下一页&nbsp;&nbsp;";

					}else{

					echo "<a href=".$url."page=".($pageval+1).">下一页</a>&nbsp;&nbsp;";

					}

					if($pageval<$pagecount){

					echo "<a href=".$url."page=".$pagecount.">末页</a>&nbsp;&nbsp;";

					}else{

					echo "末页&nbsp;&nbsp;";

					}

					

					echo "共&nbsp;<font color='red'>".$news_nums."</font>&nbsp;条文章&nbsp;&nbsp;";

					echo "页次：<font color='red'>".$pageval."&nbsp;/&nbsp;</font>".$pagecount."&nbsp;页&nbsp;&nbsp;";

					echo "转到：<select name='page' onChange='javascript:document.pageform.submit()'>";

					for($i=1;$i<=$pagecount;$i++){

						if($i==$pageval){

							$selectval="selected";

						}

						echo "<option value=".$i." ".$selectval.">".$i."</option>";

						$selectval="";

					}

					echo "</select>";

						

			}

	?>

      </td>

    </tr>

</table>

</form>

</body>

</html>

